<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
	<title>配送关系查看（生产企业）</title>
	<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
 	
   
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>配送关系查看</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">采购目录管理</a></li>
            <li class="active"><a href="#">商品目录管理</a></li>
            <li class="active"><a href="#">配送关系查看</a></li>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class="form-inline">
                    
                    <div class="form-group form-group-xs">
                       &nbsp;&nbsp;&nbsp; <label for="txtDrugForm">药品编码：</label>
                        <input class="form-control" type="text" id="drugCode" name="drugCode" placeholder="药品编码" ></input>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="txtDrugForm">&nbsp;&nbsp;通用名：</label>
                        <input class="form-control" type="text" id="drugName" id="drugName" placeholder="通用名" />
                    </div>
                     <div class="form-group form-group-xs">
                        <label>配送企业：</label>
                        <input type="hidden" id="prodPompId" name="prodPompId" value="">
                        <input class="form-control" readonly="readonly" id="comp" name="comp" type="text" placeholder="生产企业" />
                    <a href="javascript:void(0)" onclick="selectComp();" class="btn btn-default btn-sm" >选择</a>
                   </div>
                   <div class="form-group form-group-xs">
                        <label for="txtDrugComp">商品分类：</label>
                        <select class="form-control" id="drugCat" name="drugCat" style="width: 140px;">
                        </select>
                    </div>
                     <div class="form-group form-group-xs">
                        <label for="txtDrugComp">状态：</label>
                        <select class="form-control" id="status" name="status" style="width: 140px;">
                        <option value="">请选择</option>
                        <option value="0">未确认</option>
                        <option value="1">已确认</option>
                        <option value="2">拒绝</option>
                        </select>
                    </div>
                    <button type="button"  onclick="gridSerch()"  class="btn btn-success btn-sm">查&nbsp;询</button>
                </div>
            </div>
        </div>
         
        <table class="jqgrid" id="list4"></table>
        <div id="prowed2"></div>
        <div class=" box box-warning bottongroup" id="bottongroup">
		<input type="BUTTON" id="bedata1" onclick="window.location.href='${ctx}/baseGoods/toProDelDrugList.html'"  class="btn btn-default btn-sm" value="返 回" />
		</div>

            <div class="modal fade" id="selectComp" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header bg-primary">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h5 class="modal-title" id="exampleModalLabel">选择配送企业</h5>
                    </div>
                    <div class="modal-body">
                        <form>
                        <div class=" box box-success">
            <div class="box-body">
            <div class="form-inline">
                    <div class="form-group form-group-xs">
                         企业编码： 
                        <input class="form-control" type="text" id="compCode" placeholder="企业编码" />
                    </div>
                    <div class="form-group form-group-xs">
                         企业名称： 
                        <input class="form-control" type="text" id="compName" placeholder="企业名称" />
                    </div>
                    
                    <button type="button" onclick="gridCompSerch()" class="btn btn-success btn-sm">查询</button>
                </div>
            </div>
        </div>
                        
                        <div class="form-group form-group-xs">
                                <table class="jqgrid col-sm-1" id="gridlist1"></table>
        <div id="gridpage1 col-sm-1"></div>
                            </div>
                        
                        
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" onclick="gridOk()" class="btn btn-primary btn-sm">选择</button>
                        <button type="button" class="btn btn-danger btn-sm" onclick="cleandata()">清空</button>
                    </div>
                </div>
            </div>
        </div>
          <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <table id="listy"></table>
                    <div id="prowedy"></div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" onclick="save();" class="btn btn-primary btn-sm">保存</button>
                        <button type="button" class="btn btn-danger btn-sm" data-dismiss="modal">关闭</button>
                    </div>
                </div>
            </div>
            
	<table class="jqgrid" id="list4"></table>
<div style="margin-top: 10px;"></div>
</section>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">


$(function () {
jQuery("#list4").jqGrid({
	url: "${ctx}/baseGoods/getBaseDelByCompList.html?goodsCode=${goodsCode}",
    mtype: "POST",
	datatype: "json",
	autowidth: true,
	multiselect:true,
	height: 250,
   	colNames:['id','商品编码','药品编码','通用名','配送企业','配送地区','剂型','规格','转换系数','单位','商品分类','状态','操作'],
   	colModel:[
{name:'delRelId',index:'delRelId',key:true,hidden:true, width:100, sorttype:"date"},
		{name:'goodsCode',index:'goodsCode',hidden:true, width:100, sorttype:"date"},
		{name:'drugCode',index:'goodsCode', width:100, sorttype:"date"},
   		{name:'drugName',index:'drugName', width:120, sorttype:false},
   		{name:'compName',index:'compName', width:140, sorttype:false},
   		{name:'areaName',index:'areaName', width:140, sorttype:false},
   		{name:'formName',index:'formName', width:60, align:"center"},
   		{name:'specName',index:'specName', width:80, align:"left",sorttype:false},
   		{name:'factor',index:'factor', width:60, align:"left",sorttype:false},
   		{name:'unit',index:'unit', width:60, align:"center",sorttype:false},
   		{name:'drugCat',index:'drugCatText', width:180, align:"left",sorttype:false},
   		{name:'statusText',index:'statusText', width:80, align:"left",sorttype:false},
		{name:'oper',index:'oper', width:80, align:"center",
   			formatter : function(val, opts, rowdata) {
   				var str = "";
   				str += "<a href=\"${ctx}/baseGoods/toBaseDelLogList.html?delRelId="+rowdata.delRelId+"\">设置日志</a>";
   				
	   			return str;
			}	
		}
   	],
	 rowNum: 10,
     rowList: [10, 20, 30],
     rownumbers: true,
     multiselect: true,
     pager: "#prowed2",
     viewrecords: true,
     caption: "商品编码：${goodsCode}",
     editurl:"proPlanItemListHis.jsp",
     jsonReader: {
         repeatitems: false,
         id: "delRelId"
     }
   	
});
	 
	jQuery("#list4").jqGrid('navGrid',"prowed2",{edit:false,add:false,del:false});
	
	
	$("#drugCat").HNSelect({
        url: "${pageContext.request.contextPath}/selectController/getDicSys.html", data: { ID: '115' },defaultselect:'${form.patternType}',  defaultText: "<option value=''>请选择</option>",
    });
});

function gridSerch() {
	var goodsCode = $.trim($("#goodsCode").val());
	var drugCode = $.trim($("#drugCode").val());
	var drugName = $.trim($("#drugName").val());
	var prodPompId = $.trim($("#prodPompId").val());
	var drugCat = $.trim($("#drugCat").val());
	var status = $.trim($("#status").val());
	$("#list4").jqGrid('setGridParam',{  
        datatype:'json',
        postData:{"goodsCode":goodsCode,
        		"drugCode":drugCode,
        		"drugName":drugName,
        		"prodPompId":prodPompId,
        		"drugCat":drugCat,
        		"status":status}
    }).trigger("reloadGrid"); //重新载入  
}

    
	
    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = parent.window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }
    if(getQueryString("username")=="root"){
    	$("#bedata1").show();
    	$("#allDelete1").show();
    	$("#bedata2").show();
    	$("#allDelete2").show();
    	
    }else if(getQueryString("username")=="yy001"){
    	document.getElementById("yy001").style.display="";
    }else if(getQueryString("username")=="ps001"){
    	document.getElementById("ps001").style.display="";
    }
    function editPsComp() {
		$('#editPsComp').modal({
			keyboard : true
		});
	}
    
    function stop(){
    	var checked = false;
    	 $("input.cbox").each(function() {
    	     if($(this).is(":checked")) {
    	    	 checked = true;
    	    	 return false;
    	     };
    	 });
    	 
    	 if (!checked) {
    		 $.HN.message.alert('请选择要停用的条目', '提示信息', 'failed');
    	 }else{
   	 $.HN.message.confirm("确定要停用吗？", '', '').on(function (e) {
           if (e) {
               $.HN.message.alert('操作成功！', '提示信息', 'success');
               window.location.href="onSellDrugListCenter.jsp";
               
           }
       });
       }
    }
   $("#allDelete1").click(function(){
	   var checked = false;
   	 $("input.cbox").each(function() {
   	     if($(this).is(":checked")) {
   	    	 checked = true;
   	    	 return false;
   	     };
   	 });
   	 
   	 if (!checked) {
   		 $.HN.message.alert('请选择要启用的条目', '提示信息', 'failed');
   	 }else{
     	 $.HN.message.confirm("确定要启用吗", '', '').on(function (e) {
              if (e) {
                  $.HN.message.alert('操作成功！', '提示信息', 'success');
                  window.location.href="onSellDrugListCenter.jsp";
                  
              }
          });
   	 }
     });
   
	function goJsp(n1){
		
		var opt ={
				url:"../../jsp/price/priceChangeExeDetailGrid.jsp",
				title:"newwindow",
style:{height:400,width:890,top:200,left:270}
		};
		$.HN.dialog.open(opt);
		
}
	 
	$("#gridlist1").jqGrid({
        url: "${pageContext.request.contextPath}/stdCompinfo/stdCompinfoList.html",
        mtype: "POST",
        datatype: "json",
        autowidth: true,
        height: 255,
        shrinkToFit: false,
        colNames: ['id','企业编码','企业名称', '组织机构代码','法人代表'],
        colModel: [
 { name: 'compId',hidden:true,key:true, index: 'sdate', width: 90, align: "center"},
 			{ name: 'compCode', index: 'sdate', width: 90, align: "center"},
            { name: 'compName', index: 'sdate', width: 250, align: "left"},
            { name: 'orgCode', index: 'name', width:100, align: "center" },
            { name: 'lrName', index: 'name', width:80, align: "center" }
        ],
        rowNum: 10,
        rowList: [10, 20, 30],
        rownumbers: true,
        pager: "#gridpage1",
        //multiselect: true, 
        viewrecords: true,
        caption: "企业选择", 	
        jsonReader: {
            repeatitems: false,
            id: "ids"
        }
    });
    $("#gridlist1").jqGrid('navGrid', '#gridpage1', { add: false, edit: false, del: false, search: false, refresh: false });
    $(window).trigger("resize");
    
	
    
    function selectComp(){
 	   
 		$("#compCode").val("");
 	    $("#compName").val("");
 	 gridCompSerch();
 	   $('#selectComp').modal({
 			keyboard : true
 		});
 	   
 	  // window.open("${pageContext.request.contextPath}/stdDrug/toSelectComp.html?value=prodPompId&text=comp","newwin","dialogHeight: 200px; dialogWidth: 150px; dialogTop: 458px; dialogLeft: 166px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;");
    }
    function gridCompSerch() {
    	var compCode = $("#compCode").val();
    	var compName = $("#compName").val();
 		$("#gridlist1").jqGrid('setGridParam',{  
 	        datatype:'json',
 	        postData:{"compCode":compCode,
 	        		"compName":compName}
 	    }).trigger("reloadGrid"); //重新载入  
 	}
    function gridOk(){
 	   var compId = $("#gridlist1").jqGrid('getGridParam', 'selrow');
        if (compId == null) {
     	   $.HN.message.alert('请至少选一行！', '提示信息', 'error');
            return;
        }
        var rowdata = $("#gridlist1").jqGrid('getRowData', compId);
        $("#prodPompId").val(compId);
        $("#comp").val(rowdata.compName);
        $("#selectComp").modal("hide");
        
    }
    function cleandata(){
 	   $("#prodPompId").val("");
        $("#comp").val("");
        $("#selectComp").modal("hide");
    }
    
    	function changeStatus(id) {	
    		$.post("${ctx}/baseDel/changeStatus.html", {
        		delRelId : id
    		}, function(result) {
    			if (result.success) {
    				var curpage = $("#gridlist").jqGrid('getGridParam', 'page');
    				gridSerch(curpage);
    				$.HN.message.alert("操作成功！", "消息", "success");
    			} else {
    				$.HN.message.alert("操作失败！", "消息", "error");
    			}
    		}, "json")
    	}
</script>
</body>
</html>